<template>
    <div id="app">
        <div>
            <header class="site-header jumbotron">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12">
                            <h1>请发表对Vue的评论</h1>
                        </div>
                    </div>
                </div>
            </header>
            <div class="container">
                <!--<Add :addCommont="addCommont"/>-->
                <Add @addCommont="addCommont"/>
                <List :commonts="commonts" @deleteText="deleteText"/>
            </div>
        </div>
    </div>
</template>

<script>
    import Add from './components/Add'
    import List from './components/List'
    export default {
        name: "App",
        components:{
            Add,
            List
        },
        data () {
            return {
                //数据在哪里，操作数据就在那里
                commonts:[
                    {
                        name:'blo',
                        text:'Vue 上手容易'
                    },
                    {
                        name:'cat',
                        text:'Vue ssoso'
                    },
                    {
                        name:'jack',
                        text:'so good'
                    }
                ]
            }
        },
        methods:{
            addCommont (data) {
                this.commonts.unshift(data);
            },
            deleteText (index) {
                this.commonts.splice(index,1);
            }
        }
    }
</script>

<style>

</style>